#!/bin/bash
mkdir -p ./log
# 1- lib, 2-bench
curpath=`pwd`
AARCH64_PLATFORM=`uname -a | grep "aarch64"`
if [ ! -n "$AARCH64_PLATFORM" ] ; then
	NICE=""
else
	NICE="nice -n -20"
fi

do_bench() {
	# $1 libpath
	# $2 benchpath
	echo "LD_PRELOAD=$1 $2"
	${NICE} ${PERF} env LD_PRELOAD=$1 $2 2> ./log/tmp.tsv
	cat ./log/tmp.tsv
	cat ./log/tmp.tsv | while read line
	do
		echo "$3 ${line}" >> $4
	done
	# 确保文件已写入, 防止影响下一次执行
	sleep 1
}

liblist="flat
cacflat
sffwd
cacsffwd
ccsync
cacccsyn
dsmsync
cacdsmsyn
hsync
cachsyn
rcl
ffwd"

wcetliblist="mutex
pspin
spin
ticket
clh
mcs
flat
cacflat
sffwd
cacsffwd
ccsync
cacccsyn
dsmsync
cacdsmsyn
hsync
cachsyn
rcl
ffwd"